﻿<!DOCTYPE html>
<html>
<head>
	<title>DragSort Example</title>
	<meta charset="utf-8" />
	<style type="text/css">
		body { font-family:Arial; font-size:12pt; padding:20px; width:820px; margin:20px auto; border:solid 1px black; }
		h1 { font-size:16pt; }
		h2 { font-size:13pt; }
		ul { margin:0px; padding:0px; margin-left:20px; }
		#list1, #list2 { width:350px; list-style-type:none; margin:0px; }
		#list1 li, #list2 li { float:left; padding:5px; width:100px; height:100px; }
		#list1 div, #list2 div { width:90px; height:50px; border:solid 1px black; background-color:#E0E0E0; text-align:center; padding-top:40px; }
		#list2 { float:right; }
		.placeHolder div { background-color:white !important; border:dashed 1px gray !important; }
	</style>
</head>
<body>
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src="jquery.dragsort-0.5.2.min.js"></script>
	
	<h1>jQuery List DragSort Example</h1>
	
	<a href="http://dragsort.codeplex.com/">Homepage</a><br/>
	<br/>

	<h2>Simple 1D list:</h2>
	
	<ul>
		<li>bread</li>
		<li>vegetables</li>
		<li>meat</li>
		<li>milk</li>
		<li>butter</li>
		<li>ice cream</li>
	</ul>
	<br/>
	
	<script type="text/javascript">
		$("ul:first").dragsort();
	</script>
	
	<h2>2D list with drag and drop between lists:</h2>
	
	<ul id="list2">
		<li><div>10</div></li>
		<li><div>11</div></li>
		<li><div>12</div></li>
		<li><div>13</div></li>
		<li><div>14</div></li>
		<li><div>15</div></li>
		<li><div>16</div></li>
		<li><div>17</div></li>
		<li><div>18</div></li>
	</ul>
	
	<ul id="list1">
		<li><div>1</div></li>
		<li><div>2</div></li>
		<li><div>3</div></li>
		<li><div>4</div></li>
		<li><div>5</div></li>
		<li><div>6</div></li>
		<li><div>7</div></li>
		<li><div>8</div></li>
		<li><div>9</div></li>
	</ul>
	
	<!-- save sort order here which can be retrieved on server on postback -->
	<input name="list1SortOrder" type="hidden" />

	<script type="text/javascript">
		$("#list1, #list2").dragsort({ dragSelector: "div", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" });
		
		function saveOrder() {
			var data = $("#list1 li").map(function() { return $(this).children().html(); }).get();
			$("input[name=list1SortOrder]").val(data.join("|"));
		};
	</script>

	<div style="clear:both;"></div>

	<h2>Usage</h2>
	
	<p>$("ul").dragsort({ dragSelector: "li", dragEnd: function() { }, dragBetween: false, placeHolderTemplate: "&lt;li&gt;&lt;/li&gt;" });</p>
	<p>$("ul").dragsort("destroy");</p>
	<br/>

	<dl>
		<dt>dragSelector</dt>
		<dd>The <a href="http://api.jquery.com/category/selectors/">CSS selector</a> of the element inside the list item to act as the drag handle. The default is the list item itself e.g. LI.</dd>
		<dt>dragSelectorExclude</dt>
		<dd>The css selector of the elements inside the dragSelector to not trigger dragsort. The default is "input, textarea".</dd>
		<dt>itemSelector</dt>
		<dd>The css selector of the list items that are moveable. Will only match elements that are immediate children of list container. The default is tag name of first child e.g. LI.</dd>
		<dt>dragEnd</dt>
		<dd>The callback function that will be called after the dragging has ended (only called if the list order has changed). The keyword "this" in function will refer to list item that was dragged.</dd>
		<dt>dragBetween</dt>
		<dd>Set to "true" if you want to enable the ability to drag between selected lists or to allow dragging of the list item outside of the list for auto scroll. The default is false.</dd>
		<dt>placeHolderTemplate</dt>
		<dd>The html of the place holder for the dragged item. The default is empty list item e.g. "&lt;li&gt;&lt;/li&gt;".</dd>
		<dt>scrollContainer</dt>
		<dd>The css selector of the element that is to act as the scroll container e.g. a div with overflow set to auto. The default is window.</dd>
		<dt>scrollSpeed</dt>
		<dd>A number that represents the speed that the page will scroll when dragging an item outside the scroll container, a higher value is faster and a lower value is slower. Set to 0 to disable scrolling. The default is 5.</dd>
	</dl>
</body>
</html>
